/**
 * Desktop Like Interface WindowControler
 * copyrigth 2006-2007 geolabs
 * GPL-2.0
 * gerald@djayux.net
 *
 */
System.require("Window");

WindowControler=Controler.extend();

WindowControler.define({

  _init: function(n,size,coord){
    
      this.name=n[0];
      this.width=size[0];
      this.height=size[1];
      this.coord_x=coord[0];
      this.coord_y=coord[1];
      this.request=null;


      eval(this.name+'Win=new Window({name: "'+n[0]+'Win", title: "'+n[1]+'", x: '+coord[0]+', y: '+coord[1]+', width: '+size[0]+', height: '+size[1]+'})');
      this.window=eval(this.name+'Win');
    

      this.status=this.window.statusText;
      this.content=null;

    },

  noScroll: function(){
      this.window.noScroll();
    },

  setContent: function(content){
      System.document.getElementById(this.name+'WinC').innerHTML=content;
    },

  displayStatus: function(){
      this.superCall("displayStatus",arguments);
      this.window.displayNextStep(arguments);
    },

  newData: function(){
      try{
	this.displayStatus();
	// Mise à jour de la vue
	this.status.innerHTML="Terminé.";
	this.setContent(this.request.responseText);
	this.window.displayFinalStep();

	now1=new Date();
	now1.setMinutes(
			now1.getMinutes()-this.timeStamp.getMinutes(),
			now1.getSeconds()-this.timeStamp.getSeconds(),
			now1.getMilliseconds()-this.timeStamp.getMilliseconds()
			);

	this.status.innerHTML+=" ("+(now1.getSeconds())+"s,"+(now1.getMilliseconds())+"ms)";
	
	this.window.initializeLink();
	this.request=null;
      }
      catch(e) {
	this.displayStatus("There was an error :\n" +this.request.statusText+" "+e);
      }
    }

  });
